﻿// ----------------------------------------------------------------------------------
// <copyright file="UnitTestContext.cs" company="Christopher Hines">
// Copyright (c) 2012 All Right Reserved
// </copyright>
// <author>Chris Hines</author>
// <date>2012-03-26</date>
// <summary>
//     Unit test context
// </summary>
// ----------------------------------------------------------------------------------

namespace Copperfield.Fakes
{
    using System;

    /// <summary>
    /// Unit test context
    /// </summary>
    public class UnitTestContext : IComparable
    {
        /// <summary>
        /// Gets or sets Letter.
        /// </summary>
        public Letter Letter { get; set; }

        /// <summary>
        /// Gets or sets Number.
        /// </summary>
        public Number Number { get; set; }

        /// <summary>
        /// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
        /// </summary>
        /// <returns>
        /// A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance is less than <paramref name="obj"/>. Zero This instance is equal to <paramref name="obj"/>. Greater than zero This instance is greater than <paramref name="obj"/>. 
        /// </returns>
        /// <param name="obj">An object to compare with this instance. </param><exception cref="T:System.ArgumentException"><paramref name="obj"/> is not the same type as this instance. </exception><filterpriority>2</filterpriority>
        public int CompareTo(object obj)
        {
            if (ReferenceEquals(obj, null))
            {
                return 1;
            }

            if (ReferenceEquals(this, obj))
            {
                return 0;
            }

            var other = obj as UnitTestContext;

            if (other == null)
            {
                return 1;
            }

            if (other.Letter != this.Letter)
            {
                return 1;
            }

            if (other.Number != this.Number)
            {
                return 1;
            }

            return 0;
        }
    }
}
